package com.wyf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class HelloController {

    @GetMapping("/hello")
    @ResponseBody
    public String hello() {
        return "hello springboot";
    }


    /**
     * 转发到视图
     * @return
     */
    // @GetMapping("/index")
    // public String index(HttpServletRequest request) {
    //     request.setAttribute("msg", "这是Freemarker页面...");
    //     return "index";
    // }

    /**
     * 转发到视图
     *
     * @return
     */
    @GetMapping("/index")
    public String index(HttpServletRequest request) {
        request.setAttribute("msg", "这是Thymeleaf页面...");
        return "index";

    }
}